<?php
//连接数据库
$link = new mysqli('localhost', 'root', '654321', 'shumei19', 3306);
if (!$link) {
    exit('数据库连接失败');
}
// 设置字符集
$link->set_charset('utf8');
$username = '00000';
$password = md5('123231');
$sql = 'select * from users where username = "' . $username . '" limit 1';
$result = $link->query($sql);
if ($result->fetch_assoc()) {
    exit('该用户名已被注册');
}

$sql = 'insert into users (username, password) values ("' . $username . '", "' . $password . '")';
$result = $link->query($sql);
if ($result) {
    echo '注册成功' . $link->insert_id;
} else {
    echo '注册失败';
}


$link->close();